<?php

use think\migration\Migrator;
use think\migration\db\Column;

class FollowStatus extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('follow_status', array('engine' => 'MyISAM', 'comment' => '跟进方式表'));
        $table->addColumn('name', 'string', array('limit' => 55, 'null' => true, 'comment' => '名称'))
            ->addColumn('status', 'boolean', array('limit' => 1, 'default' => 1, 'comment' => '状态'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();



        $table = $this->table('follow_stage', array('engine' => 'MyISAM', 'comment' => '跟进阶段表'));
        $table->addColumn('name', 'string', array('limit' => 55, 'null' => true, 'comment' => '名称'))
            ->addColumn('status', 'boolean', array('limit' => 1, 'default' => 1, 'comment' => '状态'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();


        $table = $this->table('follows', array('engine' => 'MyISAM', 'comment' => '跟进任务表'));
        $table
            ->addColumn('customer_name', 'string', array('limit' => 80, 'null' => true, 'comment' => '客户名称'))
            ->addColumn('customer_title', 'string', array('limit' => 80, 'null' => true, 'comment' => '客户联系人'))
            ->addColumn('follow_time', 'string', array('limit' => 80, 'null' => true, 'comment' => '跟进时间'))
            ->addColumn('follow_contact_id', 'integer', array('limit' => 30, 'null' => true, 'comment' => '跟进联系方式'))
            ->addColumn('content', 'text', array('null' => true, 'comment' => '跟进结果'))
             ->addColumn('follow_stage_name_id', 'integer', array('limit' => 30,'null' => true, 'comment' => '跟进结果'))
            ->addColumn('update_status_id', 'integer', array('limit' => 30,'null' => true, 'comment' => '更新状态'))
            ->addColumn('then_status_id', 'integer', array('limit' => 30,'null' => true, 'comment' => '当时状态'))
            ->addColumn('customer_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '客户id'))
               ->addColumn('admin_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '跟踪人'))
            ->addColumn('status', 'boolean', array('limit' => 1, 'default' => 1, 'comment' => '状态'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();

        $table = $this->table('follow_appendix', array('engine' => 'MyISAM', 'comment' => '跟进附件表'));
        $table->addColumn('follow_name', 'string', array('limit' => 55, 'null' => true, 'comment' => '文件名字'))
            ->addColumn('follow_path', 'string', array('limit' => 255, 'null' => true, 'comment' => '文件路径'))
            ->addColumn('follow_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '跟进任务id'))
            ->addColumn('status', 'boolean', array('limit' => 1, 'default' => 1, 'comment' => '状态'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();
    }
}
